
/*     Generated by Interface Builder 
**	You may freely copy, distribute and reuse the code in this example.
**	Eric Tremblay disclaims any warranty of any kind, expressed or implied, as to
**	its fitness for any particular use.
**    July 26, 1992
*/

#import "MyObject.h"
#import <appkit/TextField.h>
#import <appkit/ScrollView.h> /* Used by setDocView */
#import <appkit/Text.h>/* Used by textLenght etc... */

@implementation MyObject

- textLengthTest:sender
/* The number of characters in the Text object . */
{
         int HowLongIsTheText;	
	 
	 document = [MyScrollView docView];

          /* assigns the length of the text in MyScrollView */
         HowLongIsTheText = [document textLength]; 

        /* Displays how many characters is in the text */
        [theTextLength setIntValue:HowLongIsTheText]; 
        return self;
}

- selectTextTest:sender
/* This selects "highlights" the text in MyScrollView */
{
     [[MyScrollView docView] selectText:document];

	return self;
 }
 
 - checkSpellingTest:sender
 /* This checks the spelling of the text in the MyScrollView document */
 {
  	document = [MyScrollView docView];
	[[MyScrollView docView] checkSpelling:document]; /* Spell check */
	[[MyScrollView docView] showGuessPanel:document]; /* Guess and replace panel */
	return self;
 }

- byteLengthTest:sender
/* This displays how many bytes are used in the text of MyScrollView */
{
       int HowManyBytes;
       document = [MyScrollView docView];
       HowManyBytes = [document byteLength]; 
       [theByteLength setIntValue:HowManyBytes];
       return self;
 }


- setTextTest:sender
/* This takes the text in setTextInput and displays it in MyScrollView */
{
       const char *inputString;
       inputString = [setTextInput stringValue];
       [[MyScrollView docView] setText:inputString];
       return self;
}

- appendTextTest:sender
/* This will get the text in appendTextInput and add it at the end of MyScrollView */
{
    	int HowLongIsTheText;
   	const char *inputString;
     
        inputString = [appendTextInput stringValue]; /* gets the inputString */
	
	document = [MyScrollView docView];
 	
	/* Determines how many characters are in MyScrollViews document */
	HowLongIsTheText = [document textLength]; 
  	
	/* Selects and empty selection, which in fact places the cursor at the end of the document */
	[document setSel:HowLongIsTheText:HowLongIsTheText];
        
	/* Replaces the selection (in this case it is empty) with inputString */
	[document replaceSel:inputString]; 

	return self;
}

- backWhite:sender
/* This will change the background color of MyScrollView */
{
   	[[MyScrollView docView] setBackgroundGray:NX_WHITE];
   	[MyScrollView display];
	return self;
}


- backBlack:sender
/* This will change the background color of MyScrollView */
{
 	[[MyScrollView docView] setBackgroundGray:NX_BLACK];
   	[MyScrollView display];
	return self;
}


- backLgray:sender
/* This will change the background color of MyScrollView */
{
 	[[MyScrollView docView] setBackgroundGray:NX_LTGRAY];
   	[MyScrollView display];
	return self;
}


- backDgray:sender
/* This will change the background color of MyScrollView */
{
 	[[MyScrollView docView] setBackgroundGray:NX_DKGRAY];
   	[MyScrollView display];
	return self;
}


- textWhite:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_WHITE];
     	[MyScrollView display];
     	return self;
 }

- textBlack:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_BLACK];
     	[MyScrollView display];
     	return self;
 }

- textLgray:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_LTGRAY];
     	[MyScrollView display];
     	return self;
 }

- textDgray:sender
/* changes the color of the text in MyScrollView */
{
     	[[MyScrollView docView] setTextGray:NX_DKGRAY];
     	[MyScrollView display];
     	return self;
 }

- PrintScroll:sender
/* This method will print the scrollView to the printer */
// Printing is rather simple; just send printPSCode: to the text view
// you wish to print. The print panel will automatically pop up and unless
// the user cancels the printout the text view will be printed.
{
  
    [[MyScrollView docView] printPSCode:self];
    return self;
 }

- PrintWindow:sender
/* This method will print the WHOLE panel to the printer */

{
  
    [TheWindow printPSCode:self];
    return self;
 }

@end
